<?php
class auxChiffreForm extends BaseForm
{
  public function configure()
  {
  	$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('forms');
  				$formaterName = sfConfig::get('app_form_formatterName','app');
			$this->getWidgetSchema()->setFormFormatterName($formaterName);
  }
  
  public function configureFromFournisseur($fournisseur_id, $client_id, $chiffre){
  	$i18N = sfContext::getInstance()->getI18N();
  			$q = Doctrine_Query::CREATE()
				->from('produit p')
				->addWhere('p.owner_id = ?', $fournisseur_id)
				->addWhere('p.activestatus = 0')
				->setHydrationMode(Doctrine::HYDRATE_ARRAY);
				
			$results = $q->execute();
			$attributes=array('class' => 'text');
			$attributes['tmt:pattern'] = "number";
			$attributes['tmt:message'] = $concatError . $i18N->__("Incorrect Float");
			$attributes['class'] = $attributes['class'].' form';
			foreach($results as $produit){
				$fieldName = $produit['id'];
				$this->widgetSchema[$fieldName] = new sfWidgetFormInputText();
				if(!is_null($chiffre)){
					$q = Doctrine_Query::create()->from('item_chiffre_affaires ic')
					    ->addWhere('ic.owner_id = ? ', $chiffre->id)
					    ->addWhere('ic.client_id = ?', $client_id)
					    ->addWhere('ic.produit_id = ?', $produit['id']);
				    $records = $q->execute();
				    foreach($records as $record){
				    	$item_chiffre_affaires = $record;
				    	$this->setDefault($fieldName, $item_chiffre_affaires->chiffre);
				    }
						
						
				}
				$this->offsetGet($fieldName)->getWidget()->setLabel($produit['description']);
				$this->offsetGet($fieldName)->getWidget()->setAttributes($attributes);
			}	
  }
	
}